﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YunCMS.IDAL;
using System.Reflection;

namespace YunCMS.BLL
{
    public class DALFactory
    {
        private static readonly string path = "YunCMS.SqlServerDAL";

        private static object CreateObject(string path, string type)
        {
            object objType = Assembly.Load(path).CreateInstance(type);
            return objType;
        }

        /// <summary>
        /// return YCUser object
        /// </summary>
        ///<returns>YCUserobject</returns>
        public static IYCUserDAL CreateYCUser()
        {
            string CacheKey = "YunCMS.DAL.YCUserDAL";
            object objType = CreateObject(path, CacheKey);
            return (IYCUserDAL)objType;
        }

        /// <summary>
        /// return YCCategory object.
        /// </summary>
        ///<returns>YCCategoryobject</returns>
        public static IYCCategoryDAL CreateYCCategory()
        {
            string type = "YunCMS.DAL.YCCategoryDAL";
            object objType = CreateObject(path, type);
            return (IYCCategoryDAL)objType;
        }

        /// <summary>
        /// return YCModuleArtical object.
        /// </summary>
        ///<returns>YCModuleArticalobject</returns>
        public static IYCModuleArticalDAL CreateYCModuleArtical()
        {
            string type = "YunCMS.DAL.YCModuleArticalDAL";
            object objType = CreateObject(path, type);
            return (IYCModuleArticalDAL)objType;
        }


        public static IYCModuleProductDAL CreateYCModuleProduct()
        {
            string type = "YunCMS.DAL.YCModuleProductDAL";
            object objType = CreateObject(path, type);
            return (IYCModuleProductDAL)objType;
        }

        public static IYCModulePageDAL CreateYCModulePage()
        {
            string type = "YunCMS.DAL.YCModulePageDAL";
            object objType = CreateObject(path, type);
            return (IYCModulePageDAL)objType;
        }

        public static IYCModuleFeedbackDAL CreateYCModuleFeedback()
        {
            string type = "YunCMS.DAL.YCModuleFeedbackDAL";
            object objType = CreateObject(path, type);
            return (IYCModuleFeedbackDAL)objType;
        }

        public static IYCUserRoleDAL CreateYCUserRole()
        {
            string type = "YunCMS.DAL.YCUserRoleDAL";
            object objType = CreateObject(path, type);
            return (IYCUserRoleDAL)objType;
        }

        public static IYCUserActionDAL CreateYCUserAction()
        {
            string type = "YunCMS.DAL.YCUserActionDAL";
            object objType = CreateObject(path, type);
            return (IYCUserActionDAL)objType;
        }

        public static IYCUserLogDAL CreateYCUserLog()
        {
            string type = "YunCMS.DAL.YCUserLogDAL";
            object objType = CreateObject(path, type);
            return (IYCUserLogDAL)objType;
        }
    }
}
